// -------------------------------------------------
// BlinKit SDK
// -------------------------------------------------
//   File Name: bk_js.h
//      Author: Ziming Li
//     Created: 2022-03-07
// -------------------------------------------------
// Copyright (C) 2022 MingYang Software Technology.
// -------------------------------------------------

#ifndef BLINKIT_SDK_JS_H
#define BLINKIT_SDK_JS_H

#pragma once

#include "bk_def.h"

BK_DECLARE_HANDLE(BkJSRuntime, RuntimeImpl);

#ifdef __cplusplus
extern "C" {
#endif

BKEXPORT BkJSRuntime BKAPI BkCreateJSRuntime(void);
BKEXPORT void BKAPI BkDestroyJSRuntime(BkJSRuntime rt);

enum BkJSFeature {
    BK_JS_CONSOLE          = 0x1,
    BK_JS_XML_HTTP_REQUEST = 0x2,
    BK_JS_BASE64           = 0x4,

    BK_JS_ALL_FEATURES = (BK_JS_CONSOLE | BK_JS_XML_HTTP_REQUEST | BK_JS_BASE64)
};

BKEXPORT BkJSContext BKAPI BkCreateJSContext(BkJSRuntime rt, unsigned features);
BKEXPORT void BKAPI BkReleaseJSContext(BkJSContext ctx);

BKEXPORT int BKAPI BkEvaluate(BkJSContext ctx, const char *code, unsigned len, struct BkBuffer *ret);

#ifdef __cplusplus
}
#endif

#endif // BLINKIT_SDK_JS_H
